import sys
args = sys.argv
ifile = open(args[1],'r')
line = ifile.readline()
seqname = ""
seq = ""
ofile = open(args[1].rpartition('.')[0]+'.fasta','w')

while line != '':
	if line.find('ID') != -1:
		seq = ''
		seqname =  ''
		seqname += line.partition(' ')[2].replace('\n',' ')
	if line.find('OS') != -1:
		seqname += line.partition(' ')[2].replace('\n',' ')
	if line.find('SQ') != -1:
		line = ifile.readline()
		while line.find('//')== -1:
			seq += line.replace(' ','').strip('1234567890\n')
			line = ifile.readline()	
		ofile.write('>'+seqname+'\n'+seq+'\n')
	line = ifile.readline()
ofile.close()
ifile.close()